package com.david.course_design.shopping_center.module.lunbotu.controller;

import com.david.course_design.shopping_center.module.lunbotu.entity.LunBoTu;
import com.david.course_design.shopping_center.module.lunbotu.service.LunBoTuService;
import com.david.course_design.shopping_center.result.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;


@Controller
@ResponseBody
@Api(tags = "轮播图接口")
@RequestMapping("LunBoTu/")
public class LunBoTuController {
    //  依赖注入（DI）dependency injection
    @Resource
    private LunBoTuService lunBoTuService;

    @ApiOperation("获取轮播图信息")
    @PostMapping("selectAllLunBoTu")
    private ResultBody selectAllLunBoTu() {
        List<LunBoTu> lunBoTuList = lunBoTuService.selectAllLunBoTu();

        if (lunBoTuList != null || lunBoTuList.size() != 0) {
            return ResultBody.success(lunBoTuList);
        } else {
            return ResultBody.error("请求出现错误，请稍后重试");
        }

    }

}
